<template>
  <div>
    <div>
        <sc 
        :stores="stores"
        :crops="crops"
        :batchs="batchs"
        @search="search"/>
    </div>
    <div>
      <Table stripe :columns="columns1" :data="data1" height="700" :loading="loading"></Table>
    </div>
  </div>
</template>
<script>
import sc from "../from/scsearch.vue";
export default {
  data() {
    return {
      loading:true,
      columns1: [
        {
          title: "仓库号",
          key: "sid",
          align:'center'
        },
        {
          title: "仓库名称",
          key: "sname",
          align:'center'
        },
        {
          title: "作物号",
          key: "cid",
          align:'center'
        },
        {
          title: "作物名称",
          key: "name",
          align:'center'
        },
        {
          title: "批次",
          key: "batch",
          align:'center',
          sortable: true
        },
        {
          title: "现存量",
          key: "nv",
          align:'center',
          sortable: true
        },
        {
          title: "入库时间",
          key: "intime",
          align:'center',
          sortable: true
        },
        {
          title: "临期时间",
          key: "atime",
          align:'center',
          sortable: true
        },
        {
          title: "过期时间",
          key: "endtime",
          align:'center',
          sortable: true
        },
      ],
      data1: [],
      stores:{},
      crops:{},
      batchs:[]
    };
  },
  mounted() {
    this.axios
      .get("/api/sc")
      .then((r) => {
        this.data1 = r.data.mdata;
        this.stores=r.data.stores
        this.crops=r.data.crops
        this.batchs=r.data.batches
        this.loading=false
      })
      .catch((e) => {
        this.$Message.error("E" + e);
      });
  },
  components: {
    sc,
  },
  methods:{
    search(data){
      this.axios.post('/api/sc',data).then((r)=>{
        this.data1=r.data
      }).catch((e)=>{
        this.$Message.error("e"+e)
      })
    }
  }
};
</script>
